﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

using Finance.Entites;
using Finance.UI.ViewModels;

namespace Finance.UI
{
    public partial class PeriodicDetailPage : PhoneApplicationPage
    {
        public PeriodicDetailPage()
        {
            InitializeComponent();
            this.Loaded += (o, e) => { InitializeContext(); };
        }

        private void InitializeContext()
        {
            string period = string.Empty;
            try
            {
                period = NavigationContext.QueryString["period"];
            }
            catch { period = string.Empty; }
            switch (period)
            {
                case "day": { this.DataContext = new PeriodicDetailPageViewModel(Period.Day); break; }
                case "week": { this.DataContext = new PeriodicDetailPageViewModel(Period.Week); break; }
                case "month": { this.DataContext = new PeriodicDetailPageViewModel(Period.Month); break; }
                default: { this.DataContext = new PeriodicDetailPageViewModel(Period.Week); break; }
            }
        }
    }
}